package com.hmyd.hmyd_android.ui;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.hmyd.hmyd_android.R;
import com.hmyd.hmyd_android.AppBasic;
import com.hmyd.hmyd_android.fragment.RecommendBonusListFragment;
import com.hmyd.hmyd_android.fragment.RecommendListFragment;
import com.hmyd.hmyd_android.utils.Utils;
import com.hmyd.hmyd_android.view.ViewPagerIndicator;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 好友推荐
 * 
 * @author wangc
 * 
 */
@ContentView(R.layout.activity_recommend_list)
public class RecommendListActivity extends BasicActivity {

	// 标题栏
	@ViewInject(R.id.home_title)
	public View home_title;
	@ViewInject(R.id.home_title_txt)
	public TextView home_title_txt;
	@ViewInject(R.id.home_right)
	public TextView home_right;

	private List<Fragment> mTabContents = new ArrayList<Fragment>();
	private FragmentPagerAdapter mAdapter;
	private List<String> mDatas = Arrays.asList("推荐列表", "奖金列表");

	@ViewInject(R.id.id_indicator)
	private ViewPagerIndicator mIndicator;
	@ViewInject(R.id.id_vp)
	private ViewPager mViewPager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		initDatas();
	}

	@Override
	public void onPostSuccess(int postId, String msg) {

	}

	@Override
	public void onPostFailure(int postId, String msg) {

	}

	private void initDatas() {

		RecommendListFragment fragment = new RecommendListFragment();
		mTabContents.add(fragment);

		RecommendBonusListFragment fragment2 = new RecommendBonusListFragment();
		mTabContents.add(fragment2);

		mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
			@Override
			public int getCount() {
				return mTabContents.size();
			}

			@Override
			public Fragment getItem(int position) {
				return mTabContents.get(position);
			}
		};

		mIndicator.setTabItemTitles(mDatas);

		mViewPager.setAdapter(mAdapter);

		mIndicator.setViewPager(mViewPager, 0);

	}

	@Override
	protected void setParams() {
		home_title_txt.setText("好友推荐");
		home_right.setBackgroundResource(R.drawable.hytj_icon_ewm);
		home_title.setOnTouchListener(touch);
	}

	@Override
	protected void leftButton() {
		AppBasic.getInstance().finishCurrentActivity();

	}

	@Override
	protected void rightButton() {
		/*if (AppBasic.app != null && !TextUtils.isEmpty(AppBasic.app.referrerInstructionsLinkUrl)) {
			Utils.jumpURL(this, AppBasic.app.referrerInstructionsLinkUrl, "推荐说明", "", false);
		}*/
		startActivity(new Intent(RecommendListActivity.this, InviteFriendActivity.class));
	}

}
